import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

// 定义用户类型
interface SysUser {
  id: number
  username: string
  password: string
}

// 定义用户存储
export const useUserStore = defineStore('user', () => {
  // 存储用户列表
  const users = ref<SysUser[]>([
    { id: 1, username: 'admin', password: '123456' },
    { id: 1, username: 'lzp', password: '0' },
    // 可以添加更多用户
  ])

  // 验证用户登录
  function validateUser(username: string, password: string) {
    return users.value.some((user) => user.username === username && user.password === password)
  }

  return {
    users,
    validateUser,
  }
})
